import React, { useState } from 'react';
import { Affix, Button } from 'antd';
import axios from './utils/axios';

import logo from './logo.svg';
import './App.css';
import Hello from './components/Hello';

const Demo: React.FC = () => {
  const [top, setTop] = useState(10);
  const [bottom, setBottom] = useState(10);

  return (
    <div>
      <Hello name="TypeScript" enthusiasmLevel={10} />
      <Affix offsetTop={top}>
        <Button type="primary" onClick={() => setTop(top + 10)}>
          Affix top
        </Button>
      </Affix>
      <br />
      <Affix offsetBottom={bottom}>
        <Button type="primary" onClick={() => setBottom(bottom + 10)}>
          Affix bottom
        </Button>
      </Affix>
    </div>
  );
};

function App() {
  const proxyRequest = () => {
    axios({
      method: 'get',
      url: '/mesProductType/list',
      data: {
        keyword: '',
        page: 1,
        size: 50,
      },
    }).then(
      (resp) => {
        console.log(resp);
      },
      (err) => {
        console.log(err);
      }
    );
  };
  return (
    <div className="App">
      <Button type="primary" onClick={proxyRequest}>
        proxyRequest
      </Button>
      <Demo />
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.tsx</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer">
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;
